﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Admin.Core.Common.Input;
using Admin.Core.Common.Output;
using Admin.Core.Model.Warehouse;
using Admin.Core.Service.Warehouse.XbcTypeS;
using Admin.Core.Service.Warehouse.XbcTypeS.Input;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Admin.Core.Controllers.Warehouse
{
    public class XbcTypeController :AreaController
    {
        private readonly IXbcTypeService _xbcTypeService;

        public XbcTypeController(IXbcTypeService xbcTypeService)
        {
            _xbcTypeService = xbcTypeService;
        }

        /// <summary>
        /// 查询单条物料类型信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> Get(long id)
        {
            return await _xbcTypeService.GetAsync(id);
        }


        /// <summary>
        /// 查询分页物料类型信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetPage(PageInput<XbcType> model)
        {
            return await _xbcTypeService.PageAsync(model);
        }

        /// <summary>
        /// 新增物料类型
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> Add(XbcTypeAddInput input)
        {
            return await _xbcTypeService.AddAsync(input);
        }

        /// <summary>
        /// 查询单条物料类型配置
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> GetConf(long id)
        {
            return await _xbcTypeService.GetTypeConfAsync(id);
        }


        /// <summary>
        /// 查询物料类型列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> GetXbcList()
        {
            return await _xbcTypeService.GetXbcList();
        }

       


        /// <summary>
        /// 修改物料类型
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> Update(XbcTypeUpdateInput input)
        {
            return await _xbcTypeService.UpdateAsync(input);
        }


        /// <summary>
        /// 删除物料类型
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IResponseOutput> SoftDelete(long id)
        {
            return await _xbcTypeService.SoftDeleteAsync(id);
        }

        /// <summary>
        /// 批量删除物料类型
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> BatchSoftDelete(long[] ids)
        {
            return await _xbcTypeService.BatchSoftDeleteAsync(ids);
        }

    }
}
